//
//  YHGameLayerFight.h
//  ThunderWarriors
//
//  Created by mac on 13-6-22.
//
//

#ifndef __ThunderWarriors__YHGameLayerFight__
#define __ThunderWarriors__YHGameLayerFight__

#include "YHLayer.h"
#include "cocos2d.h"
#include "YHShip.h"
USING_NS_CC;

class YHGameLayerFight : public YHLayer{
public:
    YHGameLayerFight();
    ~ YHGameLayerFight();
    virtual bool init();
    
    virtual void update(float dt);
    
    virtual void checkCollide();//检测碰撞
    virtual void removeInactiveSprite();//移除没有用处的精灵(包括超出边界的，失效的）
    
    bool loadClouds();
    void generateRandomClouds(float t); //生成云
    void removeCloud(CCNode* nodeCloud);//移除云
    
    
    //处理触摸
    virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
    virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
    virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);
    virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent);
    
    static YHGameLayerFight* sharedGameLayerFight();
    
    CREATE_FUNC(YHGameLayerFight);
    DECLARE_CREATE_CLASS(YHGameLayerFight);
    
    CC_SYNTHESIZE(CCSpriteBatchNode*, m_enemyBullets, EnemyBullets)//敌机子弹
    CC_SYNTHESIZE(CCSpriteBatchNode*, m_shipBullets, ShipBullets)//飞船子弹

private:
    YHShip* m_ship;
    CCSpriteBatchNode* m_spriteCloudsNear;
    CCSpriteBatchNode* m_spriteCloudsFar;
    CCArray* m_enemyShips;
    CCSize m_winSize;
    CCRect m_winRect;
    
    //触摸
    CCPoint m_BeginPos;
    CCPoint m_EndPos;
    CCTouch* m_pTouch;

};

#endif /* defined(__ThunderWarriors__YHGameLayerFight__) */
